<?
//announcement
$arr_annu = $DB->fetch_one_array("SELECT * FROM pa_announce WHERE an_id = 1");
$smarty->assign('ann',$arr_annu);

$key = @array_search($_SESSION[usertype],$selectpages);

$sql    = "SELECT * FROM `pa_skypechat` WHERE `sp_chattype`=0 AND `sp_top3`=1 AND `sp_status` = 1 AND FIND_IN_SET('".$key."',`sp_selectpage`) ORDER BY sp_id DESC";
$result = $DB->query($sql);
$i =0;
while($list = $DB->fetch_array($result)){
   $private[$i] = $list;
   $private[$i][sp_utype] = ($list[sp_utype]==0)?"advisordetail":"recdetail";
   $private[$i]['time']   = substr($list[sp_starttime],0,2).":".substr($list[sp_starttime],2,2)."-".substr($list[sp_endtime],0,2).":".substr($list[sp_endtime],2,2);
   $i++;
}
$count = (count($private)<3)?count($private):3;
//echo $count;
$dp = @array_rand($private, $count);
if($count > 1 ){
	for($i=0;$i<$count;$i++){
		$datav[] = $private[$dp[$i]]; 
	}
}elseif($count==1){
    $datav[] = $private[0];
}


//print_r($private);
$sql2    = "SELECT * FROM `pa_webinar` WHERE `wb_top15`=1 AND `wb_status` = 1 AND FIND_IN_SET('".$key."',`wb_selectpage`) ORDER BY wb_id DESC";
$result2 = $DB->query($sql2);
$i = 0;
while($list2 = $DB->fetch_array($result2)){
   $dsc[$i] = $list2;
   $dsc[$i][randnum] = rand(1,4);
   $dsc[$i][wb_utype]=($dsc[$i][wb_utype]==0)?"advisordetail":"recdetail";
   $dsc[$i]['time']  = substr($list2[wb_starttime],0,2).":".substr($list2[wb_starttime],2,2)." ".substr($list2[wb_starttime],4,2)."-".substr($list2[wb_endtime],0,2).":".substr($list2[wb_endtime],2,2)." ".substr($list2[wb_endtime],4,2);
   $dsc[$i][wb_color]     =  $webinar_button_colors[$dsc[$i][wb_color]];
   $i++;
}
$count = (count($dsc)<15)?count($dsc):15;
//echo $count;

$dpp = @array_rand($dsc, $count);
if($count > 1 ){
	for($i=0;$i<$count;$i++){
	   $dava[] = $dsc[$dpp[$i]];
	}
}elseif($count==1){
    $dava[] = $dsc[0];
}
if($_GET[id]=="public")
{
	$smarty->assign("public",1);
}//print_r($public);
$smarty->assign("dsc",$dava);
$smarty->assign("private",$datav);
?>